home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-07 | 2.3 KB | 82 lines | [TEXT/ALFA] |
- # FILE: date.tcl
- #
- # LAST UPDATE: 01/06/93 4:42:28 AM
- #
- # This file contains the following TCL procedure(s):
- #
- # date -- returns current date
- #
- # This proc returns current formatted date
- #
- # Optional argument: short, long, abbrev, time, weekday, month, day, year
- #
- # This proc is useful with electricAlias definitions (ie. §«date»).
- #
- # To use, simply source this file place it in the a folder with the
- # name $HOME:Tcl:Usercode: and invoke it implicitly via the "unknown proc".
- #
- # SEE ALSO unknown.tcl, electricAlias.tcl
-
- # COPYRIGHT:
- #
- # Copyright © 1992,1993 by David C. Black
- # All rights reserved.
- #
- # Redistribution and use in source and binary forms are permitted
- # provided that the above copyright notice and this paragraph are
- # duplicated in all such forms and that any documentation,
- # advertising materials, and other materials related to such
- # distribution and use acknowledge that the software was developed
- # by David C. Black.
- #
- # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
- # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- #
- ################################################################################
-
- # AUTHOR
- #
- # David C. Black
- # Internet: black@mpd.tandem.com (preferred)
- # GEnie: D.C.Black
- # USnail: 6217 John Chisum Lane, Austin, TX 78749
- #
- ################################################################################
-
- # HISTORY
- #
- # modified who rev reason
- # -------- --- --- ------
- # 01/06/93 DCB 1.0 Original
-
- proc date {{fmt ""}} {
- case "$fmt" {
- {} {
- set str [mtime [now]]
- regsub { [0-9][0-9]?:[0-9][0-9]?:[0-9][0-9]?} $str "" str
- }
- {long short abbrev} {
- set str [mtime [now] $fmt]
- regsub { [0-9][0-9]?:[0-9][0-9]?:[0-9][0-9]? [AP]M} $str "" str
- }
- {weekday month day year} {
- set str [mtime [now] long]
- regexp {([A-Z][a-z]+), ([A-Z][a-z]+) ([0-9]+), ([0-9]+)} $str all weekday month day year
- case "$fmt" {
- {weekday} {set str $weekday}
- {month} {set str $month}
- {day} {set str $day}
- {year} {set str $year}
- }
- }
- {time} {
- regexp {[0-9][0-9]?:[0-9][0-9]:[0-9][0-9] [AP]M} [mtime [now] short] str
- }
- }
- return "$str"
- }
- #endproc date
- ################################################################################
-
-